# -*- coding: UTF-8; indent-tabs-mode:nil; tab-width:4 -*-

# This file is part of DITA DTD Generator.
#
# DITA DTD Generator is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DITA DTD Generator is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DITA DTD Generator.  If not, see <http://www.gnu.org/licenses/>.

from ditagen.xml import Element as Element
from ditagen.xml import Attribute as Attribute
from ditagen.xml import ParameterEntity as ParameterEntity

class DitaElement(Element):
    """Base for DITA elements."""
    _cls = None
    def get_class(self):
        """Get element DITA class."""
        return self._cls
class TopicElement(DitaElement):
    """Topic element."""
    _name = u"topic"
    _cls = u"- topic/topic "
    _model = """(%%title;), (%%titlealts;)?,
        (%%shortdesc; | %%abstract;)%(shortdesc)s,
        (%%prolog;)?, (%%body;)?, (%%related-links;)?%(nested)s"""
    #(%%%s-info-types;)*
    _attrs = [
        Attribute("id", "ID", "#REQUIRED"),
        Attribute("conref", "CDATA", "#IMPLIED"),
        ParameterEntity("select-atts"),
        ParameterEntity("localization-atts"),
        ParameterEntity("arch-atts"),
        Attribute("outputclass", "CDATA", "#IMPLIED"),
    ]
class ConceptElement(DitaElement):
    """Concept element."""
    _name = u"concept"
    _cls = u"- topic/topic concept/concept "
    _model = """(%%title;), (%%titlealts;)?,
        (%%shortdesc; | %%abstract;)%(shortdesc)s,
        (%%prolog;)?, (%%conbody;)?, (%%related-links;)?%(nested)s"""
    _attrs = [
        Attribute("id", "ID", "#REQUIRED"),
        Attribute("conref", "CDATA", "#IMPLIED"),
        ParameterEntity("select-atts"),
        ParameterEntity("localization-atts"),
        ParameterEntity("arch-atts"),
        Attribute("outputclass", "CDATA", "#IMPLIED"),
    ]        
class TaskElement(DitaElement):
    """Task element."""
    _name = u"task"
    _cls = u"- topic/topic task/task "
    _model = """(%%title;), (%%titlealts;)?,
        (%%shortdesc; | %%abstract;)%(shortdesc)s,
        (%%prolog;)?, (%%taskbody;)?,
        (%%related-links;)?%(nested)s"""
    _attrs = [
        Attribute("id", "ID", "#REQUIRED"),
        Attribute("conref", "CDATA", "#IMPLIED"),
        ParameterEntity("select-atts"),
        ParameterEntity("localization-atts"),
        ParameterEntity("arch-atts"),
        Attribute("outputclass", "CDATA", "#IMPLIED"),
    ]
class ReferenceElement(DitaElement):
    """Reference element."""
    _name = u"reference"
    _cls = u"- topic/topic reference/reference "
    _model = """(%%title;), (%%titlealts;)?,
        (%%shortdesc; | %%abstract;)%(shortdesc)s,
        (%%prolog;)?, (%%refbody;)?, (%%related-links;)?%(nested)s"""
    _attrs = [
        Attribute("id", "ID", "#REQUIRED"),
        Attribute("conref", "CDATA", "#IMPLIED"),
        ParameterEntity("select-atts"),
        ParameterEntity("localization-atts"),
        ParameterEntity("arch-atts"),
        Attribute("outputclass", "CDATA", "#IMPLIED"),
    ]

class Domain(object):
    """Base class for domains."""
    _id = None
    _title = None
    _file = None
    _elements = None
    def __init__(self):
        pass
    def get_id(self):
        """Get domain ID."""
        return self._id
    def get_title(self):
        """Get domain title."""
        return self._title
    def get_file(self):
        """Get domain file name."""
        return self._file
    def get_elements(self):
        """Get elements domain applies to."""
        return self._elements
class UiDomain(Domain):
    """User interface domain."""
    _id = u"ui"
    _file = u"ui"
    _title = u"User Interface"
    _elements = [u"pre", u"keyword", u"ph"]
class HiDomain(Domain):
    """Hilight domain."""
    _id = u"hi"
    _file = u"highlight"
    _title = u"Highlight"
    _elements = [u"ph"]
class PrDomain(Domain):
    """Programmign domain."""
    _id = u"pr"
    _file = u"programming"
    _title = u"Programming"
    _elements = [u"pre", u"keyword", u"ph", u"fig", u"dl"]
class SwDomain(Domain):
    """Software development domain."""
    _id = u"sw"
    _file = u"software"
    _title = u"Software"
    _elements = [u"pre", u"keyword", u"ph"]
class UtDomain(Domain):
    """Utilities domain."""
    _id = u"ut"
    _file = u"utilities"
    _title = u"Utilities"
    _elements = [u"fig"]
class IndexingDomain(Domain):
    """Indexing domain."""
    _id = u"indexing"
    _file = u"indexing"
    _title = u"Indexing"
    _elements = [u"index-base"]

class Type(object):
    """DITA topic type."""
    _id = None
    _title = None
    _parent = None
    _root = None
    _owner = u"OASIS"
    def __init__(self):
        pass
    def get_id(self):
        """Get topic type ID."""
        return self._id
    def get_title(self):
        """Get topic type title."""
        return self._title
    def get_parent(self):
        """Get parent topic type."""
        return self._parent
    def get_root(self):
        """Get topic type root element."""
        return self._root
    def get_owner(self):
        """Get owner of the topic type."""
        return self._owner
class TopicType(Type):
    """Topic topic type."""
    _id = u"topic"
    _title = u"Topic"
    _parent = None
    _root = TopicElement()
class ConceptType(TopicType):
    """Concept topic type."""
    _id = u"concept"
    _title = u"Concept"
    _parent = TopicType()
    _root = ConceptElement()
class TaskType(TopicType):
    """Task topic type."""
    _id = u"task"
    _title = u"Task"
    _parent = TopicType()
    _root = TaskElement()
class ReferenceType(TopicType):
    """Reference topic type."""
    _id = u"reference"
    _title = u"Reference"
    _parent = TopicType()
    _root = ReferenceElement()
class SpecializationType(Type):
    """Specialization topic type."""
    def __init__(self, _id, title, owner):
        Type.__init__(self, _id, title, owner)
        #self._id = _id
        #self._title = title
        #self._owner = owner
